/**
 *@Time    : 2021/11/11 20:47
 *@Author  : Shuai Jhou
 *@File    : ProdService
 *@Software: GoLand
 */

package services

import (
	"context"
)

type ProdService struct {
}

func NewProdService() *ProdService {
	return &ProdService{}
}

func (s *ProdService) GetProdStock(ctx context.Context, request *ProdRequest) (*ProdResponse,
	error) {
	var stock int32 = 0
	if request.ProdArea == ProdAreas_A {
		stock = 30
	} else if request.ProdArea == ProdAreas_B {
		stock = 33
	} else {
		stock = 50
	}
	return &ProdResponse{ProdStock: stock}, nil
}

func (s *ProdService) GetProdStocks(context.Context, *QuerySize) (*ProdResponseList, error) {
	prodList := []*ProdResponse{
		&ProdResponse{ProdStock: 23},
		&ProdResponse{ProdStock: 24},
		&ProdResponse{ProdStock: 27},
		&ProdResponse{ProdStock: 28},
	}
	return &ProdResponseList{ProdRes: prodList}, nil
}

func (s *ProdService) GetProdInfo(context.Context, *ProdRequest) (*ProdModel, error) {
	ret := ProdModel{
		ProdId:    101,
		ProdName:  "JhouShuai",
		ProdPrice: 1800.5,
	}
	return &ret, nil
}
